package com.deyang.mycommon.ui.baseui;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.deyang.mycommon.application.MyApplication;
import com.deyang.mycommon.ui.baseui.BasePermissionFragment;
import com.deyang.mycommon.util.ToastUtil;

import butterknife.ButterKnife;
import butterknife.Unbinder;


/**
 * 描述:
 */
public abstract class BaseFragment extends BasePermissionFragment {
    protected String TAG;
    protected MyApplication mApp;
    protected Activity mActivity;

    Unbinder unbinder;

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        TAG = this.getClass().getSimpleName();

    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View rootView = inflater.inflate(initLayoutRes(), null);
        unbinder = ButterKnife.bind(this, rootView);
        return rootView;
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        mApp = MyApplication.getApplication();
        mActivity = getActivity();
        processLogic();

    }

    protected abstract int initLayoutRes();

    protected abstract void processLogic();

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }

    public void showToastInfo(String message) {
        ToastUtil.showInfo(message);
    }

}